﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Windows.Forms;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Nmo;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Trace;

namespace Entity
{
    public class CHUCVU
    {
        DataBaseAccess dataBaseAccess = new DataBaseAccess();

        private String MACV, TENCV;
        private float LUONGCV;

        public String maCV
        {
            get { return MACV; }
            set { MACV = value; }
        }

        public String tenCV
        {
            get { return TENCV; }
            set { TENCV = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public float luongCV
        {
            get { return LUONGCV; }
            set { LUONGCV = value; }
        }

        public void hienthi_ChucVu(DataGridView dtgChucVu)
        {
            String excuteString = "SELECT * FROM CHUCVU";
            DataTable dataTable = new DataTable();
            dataTable = dataBaseAccess.getDataTable(excuteString);
            dtgChucVu.DataSource = dataTable;
        }

        public void them_ChucVu(CHUCVU chucvu)
        {
            String excuteString = "INSERT INTO CHUCVU VALUES ('" + chucvu.maCV + "','"
                                                                 + chucvu.tenCV + "',"
                                                                 + chucvu.luongCV + ")";
            dataBaseAccess.excuteNonQuery(excuteString);
        }

        public void sua_ChucVu(CHUCVU chucvu)
        {
          String  excuteString = "UPDATE CHUCVU SET TENCV ='" + chucvu.tenCV +
                                        "', LUONGCV = " + chucvu.luongCV +
                                        " WHERE MACV ='" + chucvu.maCV + "'";
          dataBaseAccess.excuteNonQuery(excuteString);
        }

        public void xoa_ChucVu(String macv)
        {
            String excuteString = "DELETE FROM CHUCVU WHERE MACV='" + macv + "'";
            dataBaseAccess.excuteNonQuery(excuteString);
        }
    }
}
